package com.itmayiedu.core.handler;

import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 全局拦截器
 * Created by Devin on 2018/1/21.
 */
//@ControllerAdvice//切面
public class GlobalExceptionHandler {

    @ExceptionHandler(RuntimeException.class)//拦截运行时异常
    @ResponseBody
    public Map<String,Object> exceptionHandler(){
        HashMap<String, Object> result = new HashMap<String, Object>();
        result.put("code",500);
        result.put("msg","系统异常，请稍后重试！");
        return  result;
    }
}
